module.exports = (app) => {
    const { INTEGER, STRING, DATE, FLOAT } = app.Sequelize;
    const User = app.model.define("user", {
        id: {
            type: INTEGER,
            primaryKey: true,
            autoIncrement: true,
        },
        username: {
            type: STRING,
            validate: {
                is: {
                    args: /(?!\d+$)[\dA-Za-z\u4e00-\u9fa5]{5,20}/,
                    msg: "用户名为5-20位且不能为纯数字",
                },
            },
        },
        password: {
            type: STRING,
            validate: {
                is: {
                    args: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,30}$/,
                    msg: "请输入8位以上密码，密码中必须同时包含数字、字母",
                },
            },
        },
        avatarUrl: {
            type: STRING,
        },
        nickName: {
            type: STRING,
        },
        mobile: {
            type: STRING,
        },
        email: {
            type: STRING,
        },
        money: {
            type: FLOAT,
            allowNull: false,
            defaultValue: 0,
        },
        createdAt: DATE,
        updatedAt: DATE,
        status: {
            type: INTEGER,
            defaultValue: 0,
        },
    });

    return User;
};
